<?php
	global $_W,$_GPC;
	if($_W['role']){
		$uid = $_GPC['uid'];
		$tab = intval($_GPC['tab']);
		if(empty($uid)){exit(message('会员ID不存在'));}
		$o = pdo_fetch(" SELECT u.uid,u.uName,u.uPhone,u.openid,m.id as mid,m.level,m.mcard_name,m.mcard_discount,m.name,m.phone,m.balance,m.consumption,m.mcard_on,m.activation,m.actime,mc.nickname,mc.avatar FROM ".tablename('mii_ang_user')." u LEFT JOIN ".tablename('mii_ang_mcard')." m ON u.uid = m.uid  LEFT JOIN ".tablename('mc_mapping_fans').'f ON u.openid=f.openid LEFT JOIN '.tablename('mc_members')."mc ON f.uid=mc.uid WHERE u.uniacid=:uniacid AND u.uid = :uid ORDER BY u.uid DESC LIMIT 1",array(':uniacid'=>$_W['uniacid'],':uid'=>$uid));
		$order = pdo_fetchall("SELECT * FROM ".tablename('mii_ang_paylog')." WHERE uniacid=:uniacid AND openid=:openid ORDER BY oid DESC LIMIT 20",array(':uniacid'=>$_W['uniacid'],':openid'=>$o['openid']));
		$book = pdo_fetchall("SELECT o.oid,o.orderid,o.book_id,o.is_pay,o.is_ok,o.pay_money,o.tmoney,o.goods_money,o.details,o.addtime,o.order_type,g.titlepic  FROM".tablename('mii_ang_order')." o LEFT JOIN ".tablename('mii_ang_goods')." g ON o.goods_id = g.id  WHERE o.uniacid=:uniacid AND o.uid=:uid  ORDER BY o.oid DESC LIMIT 20",array(':uniacid'=>$_W['uniacid'],':uid'=>$o['uid']));
		include $this->template('web/member/memberdetails');
	}else{
		message('没有操作权限');
	}
	function deser($options,$key){
		$data = unserialize($options);
		return $data[$key];
	}
	function dejson($options,$key){
		$data = json_decode($options,true);
		return $data[$key];
	}
	function memberlevel($m){
		global $_W;
		include MODULE_ROOT.'/public/mcard/mcardinfo.'.$_W['uniacid'].'.php';
		$arr = $mcardinfo;
		$ac = $m;
		$islevel = $arr['islevel'];
		$df_level = array('mcard_level_name'=>$arr['default_mcard_level_name'],'mcard_level_discount'=>$arr['default_mcard_level_discount']); 
		if(empty($arr)){ return false;}
		if($islevel=='-1')
		{ 			
			return $df_level;
		 }
		if(is_array($arr['member_level_info'])){
			foreach ($arr['member_level_info'] as $key => $v) {
				if(floatval($ac) >= floatval($v['mcard_level_condition'])){
					$arrAy = array('mcard_level_name'=>$v['mcard_level_name'],'mcard_level_discount'=>$v['mcard_level_discount']);
					break;
				}
			}
		}
		if($arrAy){
			return $arrAy['mcard_level_name'];
		}else{
			return $df_level['mcard_level_name'];
		}
	}				
?>